#pragma once
#include <pthread.h>
class mutex
{
public:
    mutex() : _mutex(new pthread_mutex_t)
    {
        pthread_mutex_init(_mutex, nullptr);
    }

    int lock()
    {
        return pthread_mutex_lock(_mutex);
    }

    int unlock()
    {
        return pthread_mutex_unlock(_mutex);
    }

    pthread_mutex_t *get()
    {
        return _mutex;
    }

    ~mutex()
    {
        pthread_mutex_destroy(_mutex);
        delete _mutex;
    }

private:
    pthread_mutex_t *_mutex;
};